<script>
import axios from "axios";
import global from "@/views/global/global";

export default {
  name: "ProofOfIncome",
  data(){
    return{
      realName:global.user.realName,
      income:{
        userId:global.user.id,
        applicationDate:new Date(),
        department:global.user.departmentName,
        position:global.user.title,
        reason:'',
      }
    }
  },
  methods: {
    getData() {
      if(this.income.reason === null || this.income.reason === ''){
        this.$message({
          type: 'warning',
          message: '请输入事由!'
        });
        return;
      }
      this.$confirm('确定提交吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {

      axios.post("/oa/income/addition", this.income).then((res) => {
        console.log(res.data.result)
        if (res.data.result === "true") {
          this.$message({
            type: 'success',
            message: '提交成功!'
          });
          this.$router.push('/HomePageView')
        } else {
          this.$message({
            type: 'error',
            message: '提交失败!'
          });
        }
      })
    }).catch(
          () => {
            this.$message({
              type: 'info',
              message: '已取消'
            });
          }
      );
    },
    cancel() {
      // 返回到我的桌面
      this.$router.push('/HomePageView')
    }
  }

}
</script>

<template>
  <div class="titleBox" >收入证明流程</div>

  <el-form
      label-width="auto"
      :model="book"
      style="max-width: 600px"
  >
    <el-form-item label="姓名" >
      <span>{{this.realName}}</span>
    </el-form-item>

    <el-form-item label="申请时间" >
      <el-date-picker disabled
                      v-model="income.applicationDate"
                      type="datetime"
      />
    </el-form-item>

    <el-form-item label="部门">
      <span>{{income.department}}</span>
    </el-form-item>

    <el-form-item label="岗位">
      <span>{{income.position}}</span>
    </el-form-item>


    <el-form-item label="申请事由">
      <el-input  type="textarea" v-model="income.reason"
                 placeholder="请输入事情和原因"/>
    </el-form-item>

<!--    <el-form-item label="下一步审批人">
      <el-select v-model="income.userId" placeholder="审批人" style="width: 240px">
        &lt;!&ndash;        默认选中当前用户&ndash;&gt;
        <el-option
            :key="this.realName"
            :label="this.realName"
            :value="this.realName"
        />
      </el-select>
    </el-form-item>-->
    <el-button type="primary" @click="getData()">确定</el-button>
    <el-button @click="cancel">取消</el-button>
  </el-form>
</template>

<style scoped lang="less">

</style>
